<?php
	####################################################
	# library import and object instance.              #
	####################################################
	include_once('./common.php');


	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	$req = Request::clean_request($_REQUEST, FALSE);

	# GET(url variables)

	# POST(form variables)

	# Validation(special case validate)
	//*/
	Validation::check_is_emptys($req);
	Validation::check_is_email($req['cert_email']);
	//Nlog::xmp($req); //display clean and remmap values
	//*/
	####################################################
	# implementation                                   #
	####################################################

	//*/
	# 세션에 muid값을 확인 후 없으면 error
	if(empty($_SESSION['muid']) == TRUE){
		Mover::error("error", NULL);
	} else {
		//Nlog::xmp($_SESSION);
	}

	# 인증 메일과, 인증 키로 값을 가져온다.
	$ret = $db->gets(
		sprintf("SELECT * FROM `n_certmail` WHERE `cert_email`='%s' AND `cert_key`='%s' ORDER BY uid DESC",
			$req['cert_email'],
			$req['cert_key']
		)
	);
	if($ret['has']){
		# 인증 성공.
		$flag_cert = TRUE;
	}
	//Nlog::xmp($ret);
	//*/

?>
<?php
	$html->custom_header(TITLE);
	$html->custom_js("{$JS}jquery.1.7.1.min.js");
	$html->custom_js("{$JS}lib.control.js");
	$html->custom_css("{$CSS}basic.css");
?>
<script type="text/javascript" language="javascript">
//<![CDATA[
	var PageAction = {
		validate:function(){
			//*/
			var check = [
				Validation.check_is_null("#mpasswd", "새로운 비밀번호를 입력하세요."),
				Validation.check_is_idpw("#mpasswd", "새로운 비밀번호를 형식에 맞게 입력하세요."),
				Validation.check_is_null("#mpasswdc", "새로운 비밀번호확인을 입력하세요."),
				Validation.check_is_idpw("#mpasswdc", "새로운 비밀번호확인을 형식에 맞게 입력하세요."),
				Validation.check_is_equal("#mpasswd", "#mpasswdc", "새로운 비밀번호와 새로운 비밀번호확인이 일치하는지 확인하세요.")
			];
			return Validation.check(check);
			//*/
		}
	}
//]]>
</script>
<?$html->custom_body();?>
<?=$tmp->tiles_header()?>
	<h1>비밀번호 찾기</h1>
	<?php if($flag_cert): ?>
		<form id="formx" name="formx" method="post" action="./sign_passwd_find_proc.php" onsubmit="return PageAction.validate();">
			<table width="100%" border="1" cellspacing="3" cellpadding="0">
				<tr>
					<th>
						새로운 비밀번호
					</th>
					<td>
						<input type="password" name="mpasswd" id="mpasswd" />
					</td>
				</tr>
				<tr>
					<th>
						새로운 비밀번호확인
					</th>
					<td>
						<input type="password" name="mpasswdc" id="mpasswdc" />
					</td>
				</tr>
				<tr>
					<th colspan="2">
						<?=NTool::submit_btn();?>
					</th>
				</tr>
			</table>
		</form>
	<?php else: ?>
		일치하는 정보가 없습니다.
	<?php endif; ?>
	<?=NTool::btn("뒤로", "Mover.back();");?>
	<?=NTool::btn("인덱스", "Mover.home();");?>
<?=$tmp->tiles_footer()?>
<?php $html->html_footer(); ?>